package cn.phantom.pooltest;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j(topic = "c.Test4")
public class Test4 {
    static int i = 0;
    public static void main(String[] args) throws InterruptedException {
        test1();
    }

    private static void test1() throws InterruptedException {
        log.debug("start.");
        Thread t1 = new Thread(() -> {
            log.debug("start.");
            try {
                TimeUnit.MILLISECONDS.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            log.debug("end.");
            i = 10;
        }, "t1");

        t1.start();
        t1.join(); // 加上join结果为10
        log.debug("i = {}", i); //加上join结果i=0
        log.debug("end.");

    }
}
